#include <stdlib.h>
#include <signal.h>
#include <stdio.h>
#include <sys/wait.h>
#include <unistd.h>

/** Autuor : zhaoshun
  * Time   : 2017/11/12 20:16
  * Email  : tmby1314@163.com */

void func();

int main_ipc(int argc, char **argv) {
    int pid, status = 1;
    signal(SIGUSR1, func);
    while ((pid = fork()) == -1);
    if (pid) {
        printf("It is the parent process.\n");
        printf("Parent : will send dignal.\n");
        kill(pid, SIGUSR1);
        pid = wait(&status);
        printf("Chile process %d,status=%d\n", pid, status);
    } else {
        sleep(2);
        printf("It is the child process.\n");
        execvp("PWD", (char *) 0);
        printf("execl error.\n");
        exit(2);
    }
    printf("Parent process finish.");
}


void func() {
    system("date");
}
